package com.xiong.bistu.wetchat;
import java.util.concurrent.TimeUnit;
import okhttp3.OkHttpClient;


/**
 * @title OkHttpUtils
 * @description
 * @author Chad
 * @since 17/7/3 下午3:32
 * @modifier
 * @date
 **/
public class OkHttpUtils {
    private static OkHttpClient mOkHttpClient;
    /**
     * 获取OkHttpClient对象
     */
    public static OkHttpClient getOkHttpClient() {

        if (null == mOkHttpClient) {
            //同样okhttp3后也使用build设计模式
            mOkHttpClient = new OkHttpClient.Builder()
                    //添加网络连接器
                    //设置请求读写的超时时间
                    .connectTimeout(30, TimeUnit.SECONDS)
                    .writeTimeout(30, TimeUnit.SECONDS)
                    .readTimeout(30, TimeUnit.SECONDS)
                    .build();
        }
        return mOkHttpClient;
    }

}
